/*
 * @Descripttion:
 * @version:
 * @Author: kl2018
 * @Date: 2019-04-09 17:04:50
 * @LastEditors: kl2018
 * @LastEditTime: 2020-08-13 09:35:14
 */
import React from 'react';

import { inject, observer } from 'mobx-react';
import { WeaTools, WeaErrorPage, WeaTop, WeaLeftRightLayout, WeaLocaleProvider, WeaRightMenu } from 'ecCom';

const getLabel = WeaLocaleProvider.getLabel;


import LayoutLeftTopComp from './LayoutLeftTopComp';// 发文拟稿和收文登记按钮
import LayoutLeftOdocTypeComp from './LayoutLeftOdocTypeComp';// 公文种类分类
import LayoutLeftTopicTypeComp from './LayoutLeftTopicTypeComp';// 主题分类
// import LayoutRightSearchComp from "./LayoutRightSearchComp";//高级搜索
import LayoutRightLibraryComp from './LayoutRightLibraryComp';// 公文库
import LayoutRightTodoComp from './LayoutRightTodoComp';// 代办公文
import LayoutRightToViewComp from './LayoutRightToViewComp';

import '../../../workflow/util/windowFun';// 支持openSPA4Single,doPrintRequest,showallreceived等方法

@inject('centerStore')
@observer
class CenterComponent extends React.Component {
  componentDidMount() {
    const { centerStore } = this.props;
    window.isOdocOpenWF = true;
    window.getOdocWFList = () => {
      setTimeout(() => {
        centerStore.buildTodos();
        centerStore.buildTodoTabs();
      }, 3000);
    };
  }

  componentWillUnmount() {
    window.isOdocOpenWF = null;
    window.getOdocWFList = null;
  }

  getLeftLayout() {
    return (
      <div className="wea-odoc-center-left" >
        <LayoutLeftTopComp ecId={`${this && this.props && this.props.ecId || ''}_LayoutLeftTopComp@f5c2z5`} />
        <LayoutLeftOdocTypeComp ecId={`${this && this.props && this.props.ecId || ''}_LayoutLeftOdocTypeComp@lqjcoa`} />
        <LayoutLeftTopicTypeComp ecId={`${this && this.props && this.props.ecId || ''}_LayoutLeftTopicTypeComp@eoraga`} />
      </div>
    );
  }

  renderRight() {
    const { centerStore } = this.props;
    return (
      <div className="wea-odoc-center-right" style={{ padding: 8 }}>
        {/* <LayoutRightSearchComp /> */}
        <LayoutRightTodoComp ecId={`${this && this.props && this.props.ecId || ''}_LayoutRightTodoComp@g1wd9i`} />
        {centerStore.showToviewComp && <LayoutRightToViewComp ecId={`${this && this.props && this.props.ecId || ''}_LayoutRightToViewComp@x4oal6`} />}
        <LayoutRightLibraryComp ecId={`${this && this.props && this.props.ecId || ''}_LayoutRightLibraryComp@1gccrm`} />

      </div>
    );
  }

  render() {
    return (
      <div className="wea-odoc-center-parent">
        <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@edvm2w`} datas={[]}>
          <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@3fwxd9`}
            title={getLabel('384730', '公文中心')}
            icon={<i className="icon-coms-official" />}
            iconBgcolor={'#f14a2d'}
          >
            <div className="wea-odoc-center">
              <WeaLeftRightLayout ecId={`${this && this.props && this.props.ecId || ''}_WeaLeftRightLayout@1s2z1g`}
                showBtn={false}
                leftWidth={260}
                leftCom={this.getLeftLayout()}
              >
                {this.renderRight()}
              </WeaLeftRightLayout>
            </div>
          </WeaTop>
        </WeaRightMenu>
      </div>
    );
  }
}

export default WeaTools.tryCatch(React,
  props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@aixf90`} msg={props.error ? props.error : '对不起，该页面异常，请联系管理员！'} />,
  { error: '' },
)(CenterComponent);
